package com.kalkr;

import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;

public class KalkrFilter implements Filter {
	private FilterConfig filterConfig;
	
	public FilterConfig getFilterConfig() {
		return filterConfig;
	}
	public void init(FilterConfig filterConfig) {
		this.filterConfig = filterConfig;
	}
	public void destroy() {}

	public void doFilter(ServletRequest req, ServletResponse resp, 
			FilterChain chain)throws IOException, ServletException {
		String msg="Filtering the Request...";
		if(req instanceof HttpServletRequest) {
			System.out.println(((HttpServletRequest)req).getRequestURL().toString());
			System.out.println(((HttpServletRequest)req).getQueryString());
		}
		System.out.println(msg);
		chain.doFilter(req, resp);
		System.out.println("Filtering the Response...");
	}
}